#! /bin/csh -f

if !(-d $CASEBUILD) mkdir $CASEBUILD

#-------------------------------------------------------------------------------
# setup
#-------------------------------------------------------------------------------

set NX = $GLC_NX
set NY = $GLC_NY

# ---------------------------------------------------------------------------
#  Create resolved namelist 
# ---------------------------------------------------------------------------

cat >! $CASEBUILD/xglc.buildnml.csh << EOF1
#! /bin/csh -f 

set exedir = \$RUNDIR; cd \$exedir

cat >! xglc_in << EOF
$NX       !  i-direction global dimension
$NY       !  j-direction global dimension
2         !  decomp_type  1=1d-by-lat, 2=1d-by-lon, 3=2d, 4=2d evensquare, 11=segmented
0         !  num of pes for i (type 3 only)
0         !  length of segments (type 4 only)
EOF

EOF1

# ---------------------------------------------------------------------------
#  Create script to build dead model
# ---------------------------------------------------------------------------

cat >! $CASEBUILD/xglc.buildexe.csh << EOF2
#! /bin/csh -f 

set objdir = \$OBJROOT/glc/obj; cd \$objdir
set comp = 'unknown'
if (\$COMP_INTERFACE == 'MCT' ) set comp = mct
if (\$COMP_INTERFACE == 'ESMF') set comp = esmf

#------------------------------------------------------------------------------
# Build the library
#------------------------------------------------------------------------------
cat >! Filepath << EOF
\$CASEROOT/SourceMods/src.xglc
\$CODEROOT/glc/xglc
\$CODEROOT/glc/xglc/cpl_\$comp
EOF

gmake complib -j \$GMAKE_J MODEL=xglc COMPLIB=\$LIBROOT/libglc.a -f \$CASETOOLS/Makefile MACFILE=\$CASEROOT/Macros.\$MACH || exit 2

EOF2
